package com.scau.yangsuiyu.estore.dababases.entity;

import javax.persistence.Column;
import javax.persistence.Id;
import java.io.Serializable;
import java.util.Objects;

/**
 * @author suiyu_yang
 * @description
 * @date 2019-06-04 19:20
 * @email suiyu_yang@163.com
 */
public class CartPK implements Serializable {
    private int buyerId;
    private int itemId;

    @Column(name = "buyer_id")
    @Id
    public int getBuyerId() {
        return buyerId;
    }

    public void setBuyerId(int buyerId) {
        this.buyerId = buyerId;
    }

    @Column(name = "item_id")
    @Id
    public int getItemId() {
        return itemId;
    }

    public void setItemId(int itemId) {
        this.itemId = itemId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        CartPK cartPK = (CartPK) o;
        return buyerId == cartPK.buyerId &&
                itemId == cartPK.itemId;
    }

    @Override
    public int hashCode() {
        return Objects.hash(buyerId, itemId);
    }
}
